﻿package game 
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.xml.XMLDocument;
	import flash.xml.XMLNode;
	import game.events.EventData;
	/**
	 * ...
	 * @author Doan Nguyen Thuy Nha Truc (Bamboo)
	 */
	public class LoadXML extends EventDispatcher
	{
		private var xmlLoader:URLLoader;
		public var xmlNode:XMLNode
		
		public function LoadXML() {}
		
		public function loadData(nameXML:String):void {
			//trace(nameXML);
			xmlLoader = new URLLoader();
			xmlLoader.load(new URLRequest(nameXML));
			xmlLoader.addEventListener(Event.COMPLETE, showXML);
			
		}
		
		private function showXML(e:Event):void {			
			var data = new XMLDocument();
			data.ignoreWhite = true;
			data.parseXML(e.target.data);
			xmlNode = data.firstChild;
			dispatchEvent(new Event(EventData.LOAD_XML_COMPLETE));
		}
		
	}

}